<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>优惠券</title>
    <link rel="stylesheet" href="../css/优惠券.css">
</head>
<body>
    <div class="head">
        <a href="../pages/优惠券.html" class="left"><img src="../img/left.jpg" alt=""></a>
        <h4>优惠券</h4>
        <a href="#" class="right"><img src="../img/xiazai1.jpg" alt=""></a>
    </div>
    <main class="product">
        
    </main>

    <main class="back">
        <a href="../index.html">首页></a>
        <a href="#">优惠券</a>
    </main>
    <section id="footer">
        <div class="more">
            <a href="">更多优惠信息>></a>
        </div>
        <div id="chart">
            <span>品牌排行</span>
            <a href=""><img src="../img/left.jpg" alt=""></a>
        </div>
        <div id="login">
            <div id="row">
                <a href="">
                    <div>登入</div>
                </a>
                <a href="">
                    <div>注册</div>
                </a>
                <div class="gotop">返回顶部</div>
            </div>
            <div id="conter">
                <p>
                    <a href="">手机APP下载</a>
                    <a href="">万锋智慧商城手机版</a>
                    <span>--掌上比价平台</span>
                </p>
                <p>chst.vip:8081/cm</p>
            </div>
        </div>

    </section>
</body>
</html>
<script src="../适配/flexible.js"></script>
<script src="../jquery.min.js"></script>
<script>
    function scrollHandler() {
        const height = $(this).scrollTop()
        if (height >= 300) {
            $('.gotop').fadeIn(500)
        } else {
            $('.gotop').fadeOut(500)
        }
    }

    scrollHandler()
    $(window).scroll(scrollHandler)

    $('.gotop').click(function () {
        $('body, html').animate({ scrollTop: 0 }, 1000)
    })



    let regExp = /^<[^<]+\s+src="([^''""]*)"/
    fetch('http://chst.vip:1234/api/getcoupon')
        .then(body => body.json())
        .then(res => {
            console.log(res);
            let data = res.result
            let html = ''
            let product = document.querySelector('.product')
            data.forEach(item => {
                html += `
                <a href="../pages/优惠券列表.html">
                    <img src="${item.couponImg}" alt="">
                    <p> ${item.couponTitle}</p>  
                  </a>
                `
            })
            product.innerHTML = html
        })
</script>